﻿@using MVCMongo.Services
@model MVCMongo.ViewModel.ProfileIndexViewModel
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_LayoutProfile.cshtml";
}

@if (this.Model != null && this.Model.ChatModel.IsUserAuthenticated)
{
    <script type="text/javascript">
        $(function () {
            $.chat({
                // your user information
                user: {
                    Id: '@this.Model.ChatModel.UserId',
                    Name: '@this.Model.ChatModel.UserName',
                    ProfilePictureUrl: '@Html.Raw(this.Model.ChatModel.UserProfilePictureUrl)'
                },
                // text displayed when the other user is typing
                typingText: ' is typing...',
                // the title for the user's list window
                titleText: 'Chat',
                // text displayed when there's no other users in the room
                emptyRoomText: "No one is Online.",
                // the adapter you are using
                adapter: new SignalRAdapter() // new LongPollingAdapter()
            });
        });
    </script>
}
<div class="container-fluid">

    @Html.Partial("_PartialFeed",Model.PostType)

    <div class="span3">
        @Html.Action("FriendList")


    </div>
</div>

<script>
    @*$("#txtMessage").blur(function() {
        var status = $(this).val();

        var isUrl = ValidUrl(status);

        if (isUrl) {

            var url = "@Url.Action("StreamData","Profile")?url=" + status;
            $.ajax({
                url: url,
                type: "POST",
                success: function(data) {
                    //alert(data);
                    $("#preview-display").css("display","block");

                    $("#preview-display").html(data);
                    $("#Postsource").val("s");
                    $("#txtMessage").val("");


                },
                error: function(data){
                    alert("An error Occurred!!!");
                }
            });



        }


    });*@
    
    $("#preview-display-remove").live("click", function() {
        $("#preview-display").css("display","none");

        source = "";
    });

   
    function ValidUrl(str) {
        var pattern = new RegExp('^(https?:\\/\\/)?'+ // protocol
            '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+ // domain name
            '((\\d{1,3}\\.){3}\\d{1,3}))'+ // OR ip (v4) address
            '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // port and path
            '(\\?[;&a-z\\d%_.~+=-]*)?'+ // query string
            '(\\#[-a-z\\d_]*)?$','i'); // fragment locator
        if(!pattern.test(str)) {
            return false;
        } else {
            return true;
        }
    }

  
</script>

<style>
    .chat-window .chat-window-content .chat-window-inner-content .chat-message .chat-gravatar-wrapper img {
        height: 30px;
        width: 30px;
    }
</style>